#include "manager.h"
#include "common/vconsole.h"
#include "common/defs.h"
#include <iostream>

manager::manager()
    : __status(true)
{    
}

manager::~manager()
{
}

bool manager::init()
{
    bool init_res = true;
    
    // openGL initialization
    init_res = __scene.init_graphics();
    
    // cuda initialization
    init_res &= __cuda_controller.init();
    
    if (init_res)
    {
        __scene.create_buffer(__cuda_controller.pixel_buffer(), __cuda_controller.result_texture());
        init_res &= __cuda_controller.register_buffer();
    }

    vconsole::print_status("initialization", MANAGER, init_res);
    return init_res;
}

bool manager::main_loop()
{
    __cuda_controller.recalculate();
    __scene.draw_scene(__cuda_controller.pixel_buffer(), __cuda_controller.result_texture());
    return true;
}

void manager::start()
{
    while(__status)
    {
        main_loop();
    }
}

bool manager::calculate()
{

}
